<?php
session_start();
include('connection.php');
if(isset($_SESSION['username']) || isset($_SESSION['password']))
{
	?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">

    <title>Starter Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- Custom styles for this template -->
   

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="../../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
    
       <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>

         <script src="js/bootstrap.js"></script>  
         
         <script src="datepicker/js/bootstrap-datepicker.js"></script>
            

         <link href="datepicker/css/datepicker.css" rel="stylesheet"/>
         <link href="datepicker/less/datepicker.less" rel="stylesheet" />
      

    
    
  </head>

  <body>
  
  
  <?php include('addminmenu.php'); ?>

    
    <div class="container" style="margin-top:70px;">

      <form class="form-horizontal" role="form" id="studentform" action="" method="post" >
      <div class="col-sm-6">
      <div class="form-group">
            <label  class="col-sm-4 control-label"  >Form Number</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="form_number" placeholder="Form Number" name="form_number" required >
               <div id="form_number_span" style="display:none;color:red;font-size:13px;"> This form number is registered </div>
            </div>
        </div>
      	<h4>Personal Information</h4>
      	<div class="form-group">
            <label for="inputEmail3" class="col-sm-4 control-label"  >Full Name</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" placeholder="Full Name" name="full_name" required >
             
            </div>
        </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Date Of Birth</label>
            <div class="col-sm-8">
              <div class="input-append date" id="dpYears" data-date="12-02-2012" data-date-format="dd-mm-yyyy" data-date-viewmode="years">
				<input class="span2 form-control" size="16"  name="dob"  type="text" value="12-02-2012" placeholder="Date Of Birt" required  readonly>
				<span class="add-on"><i class="glyphicon glyphicon-calendar"></i></span>
			  </div>
            
            </div>
          </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Gender</label>
            <div class="col-sm-8">
            	<select name="gender"  class="form-control" >
            	  <option value="male">Male</option>
            	  <option value="female">Female</option>
                </select>
            </div>
          </div>
          
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Father Name</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" placeholder="Father Name" name="father_name" required>
            </div></div>
            <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Mother  Name</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" placeholder="Mother Name" name="mother_name" required>
            </div>
          </div>
            <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Profile Image</label>
            <div class="col-sm-8">
            <div id="me" class="styleall form-control" style=" cursor:pointer; "><span 
style=" cursor:pointer; width:100%; font-family:Verdana, Geneva, sans-serif; font-size:12px;">
<span style="width:100%; cursor:pointer;" >click here to upload profile Photo</span></span></div><span id="mestatus" ></span>
              <input type="hidden" class="form-control" value="" name="photo" id="filename" >
            </div>
      </div>
      <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Email</label>
            <div class="col-sm-8">
              <input type="email" class="form-control" placeholder="email" name="email" required>
            </div>
          </div>
  </div>
      <div class="col-sm-6">
  	<h4>Contact Information</h4>
  		<div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Contect No.(Parents)</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="inputPassword3" name="parent_number" placeholder="Mobile No." required>
            </div>
            
        </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Mobile No.</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="inputPassword3" name="mobile_number" placeholder="Mobile No." required>
            </div>
            
          </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Address</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="inputPassword3" name="address" placeholder="Address" required>
            </div>
            
          </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Country</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="inputPassword3" name="country" placeholder="Country" required>
            </div>
            
          </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">State</label>
            <div class="col-sm-8">
              <input type="text" class="form-control"  name="state" placeholder="State" required>
            </div>
            
          </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">City</label>

            <div class="col-sm-8">
              <input type="text" class="form-control" id="" name="city" placeholder="City" required>
            </div>
      </div>
       <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Pin</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="" name="pin" placeholder="pin" required>
            </div>
      </div>
  </div>
  <div class="col-sm-6 clearfix" style="clear:left">
  	<h4>Course Detail</h4>
      <div class="form-group">
        <label for="inputPassword3" class="col-sm-4 control-label">Course Name</label>
        <div class="col-sm-8">
      <select  class="form-control" id="" name="course_name" placeholder="Course Name"  onChange='course_fees(this.value)'>
         <option value="0">Select Course</option>
		<?php
		$sql_course="SELECT * FROM `course`";
		$result_course = mysql_query($sql_course);
		while($row_course = mysql_fetch_array($result_course))
{
echo "<option value='".$row_course['course_id']."'>".$row_course['course_name']."</option>";
}
		
		?>
          </select>
        </div>
      </div>
      <div class="form-group">
        <label for="inputPassword3" class="col-sm-4 control-label">Course Fee</label>
        <div class="col-sm-8">
      <input type="text" id="course_fee" name="course_fee"  placeholder="Course Fee" class="form-control" readonly />

        </div>
      </div>
      <div class="form-group">
         <label for="inputPassword3" class="col-sm-4 control-label">Hostel Facility</label>
        <div class="checkbox  col-sm-8">
        <select name="hostel_facility" class="form-control"  onChange='hostel_fees(this.value)'>
        <option >Select hostel Facility</option>
          <option value="1">Yes</option>
          <option value="0">No</option>
        
          </select>
        </div>
      </div>
      <div class="form-group">
        <label for="inputPassword3" class="col-sm-4 control-label">Hostel Fee</label>
        <div class="col-sm-8">
          <input type="text" class="form-control" id="hostel_fee" name="hostel_fee"  placeholder="Hostel Fee" value="" readonly    >
        </div>
      </div>
      <div class="form-group">
        <label for="inputPassword3" class="col-sm-4 control-label">Discount</label>
        <div class="col-sm-8">
          <input type="text" class="form-control" id="txtdiscount" name="discount" placeholder="Discount" onKeyUp="discount(this.value)" >
        </div>
      </div>
      <div class="form-group">
        <label for="inputPassword3" class="col-sm-4 control-label"  >Installment</label>
        <div class="col-sm-8">
          <select  id="installment" class="form-control" name="installment" onChange="Emi()">
           <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
          </select>
        </div>
      </div>
      <div class="form-group">
        <label for="inputPassword3" class="col-sm-4 control-label">Grand Totle</label>
        <div class="col-sm-8">
        <input type="text" class="form-control" id="total" name="total" placeholder="total" value="0" readonly>
          <span id="ins"></span><span id="emi"></span>
        </div>
      </div>
    </div>
  <div class="col-sm-6">
  <h4>Preivious Qualification</h4>
  		<div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Course Name</label>
            <div class="col-sm-8">
              <input type="text" class="form-control"  id="" name="previous_course_name" placeholder="previous course name">
            </div>
            
    </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">School/College Name</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id=""  name="previous_school_name" placeholder="School/College Name">
            </div>
            
          </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Board/University</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="" name="previous_board" placeholder="previous board">
            </div>
            
          </div>
           <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">Specilization</label>
            <div class="col-sm-8">
            	<input type="text" class="form-control" id="previous_specilization" name="previous_specilization" placeholder="previous specilization">
            </div>
            
          </div>
             <div class="form-group">
            <label for="inputPassword3" class="col-sm-4 control-label">percentage/CGPA</label>
            <div class="col-sm-8">
              
              <input type="text" class="form-control" id="" name="previous_percentage" placeholder="previous percentage/CGPA">
            </div>
            
          </div>
  </div>
  
  
  
  
 
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-8">
      <button type="submit" class="btn btn-default" >Submit</button>
    </div>
  </div>
</form>

<div id="show" class="container" style="display:none; width: 300px;
height: 300px;
border: 1px solid black;
background: whitesmoke;
position: absolute;
top: 120px; left:500px;">
    <p>Student Details Are Submited Successfully .</p><br>
    <div id="show1" style="height:150px;">
    </div>
     
</div>

    </div><!-- /.container -->


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->

  
     
<script type="text/javascript" src="ajax/Ajaxfileupload-jquery-1.3.2.js" ></script>
<script type="text/javascript" src="ajax/ajaxupload.3.5.js" ></script>
<link rel="stylesheet" type="text/css" href="ajax/Ajaxfile-upload.css" />

   

     <script type="text/javascript">
	 $(document).ready(function(){
	 $('#form_number').focusout(function() {
		checkformnumber($(this).val())
	 }); });
	 
	 jQuery.noConflict();
	  $(function(){
		 
    $("#studentform").submit(function(e){
       e.preventDefault();
 
      
			dataString= $('#studentform').serialize();
			$.ajax({
			
			type: "POST",
			url: "formconfiron.php",
			data: dataString,
				success: function(response){
					
					$('#show').show();
					$('#show1').html(response);
				
		}
		});
		 });
		
		 

	 
		var btnUpload=$('#me');
		var mestatus=$('#mestatus');
		var files=$('#files');
		new AjaxUpload(btnUpload, {
			action: 'upload.php',
			name: 'uploadfile',
			onSubmit: function(file, ext){
				 if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ 
                    // extension is not allowed 
					mestatus.text('Only JPG, PNG or GIF files are allowed');
					return false;
				}
				mestatus.html('<img src="ajax-loader.gif" height="16" width="16">');
			},
			onComplete: function(file, response){
				//On completion clear the status
				mestatus.text('Photo Uploaded Sucessfully!');
				//On completion clear the status
				files.html('');
				//Add uploaded file to list
				if(response==="success"){
				 $('#filename').val(file);
					} else{
					$('<li></li>').appendTo('#files').text(file).addClass('error');
				}
			}
		});
		 $('#dpYears').datepicker();
  $('#txtdiscount').keyup(function(){
	discount($(this).val());
	  
  });
 
 });
//function grandcal()
//{
//	var cf = $('#course_fee').val();
//	var hf = $('#hostel_fee').val();
//	var di = $('#txtdiscount').val();
//	var discount= parseInt((coursefee+hostelfee)*str/100);
//	var GrantTotal=(coursefee+hostelfee)-discount;
//	$("#total").val(GrantTotal);
//	
//	
//}
function course_fees(str)
{
	
if (str=="0")
  {
 
  $('#course_fee').val("");
  grandTotal();
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    $("#course_fee").val(xmlhttp.responseText); 
	
    }
	  grandTotal();
	
  }
xmlhttp.open("GET","coursefees.php?q="+str,true);
xmlhttp.send();

}
function hostel_fees(str)
{
	 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    $("#hostel_fee").val(xmlhttp.responseText);
	    }
		grandTotal();
  }
xmlhttp.open("GET","coursefees.php?p="+str,true);
xmlhttp.send();

}
function discount(str)
{  
      var discount;
	 var coursefee= isNaN(parseInt($('#course_fee').val()))? 0 :parseInt($('#course_fee').val()) ;
	var hostelfee= isNaN(parseInt($('#hostel_fee').val()))? 0 :parseInt($('#hostel_fee').val()) ;
	if(str != ""){
	discount= parseInt((coursefee+hostelfee)*str/100);
	}
	else{
	discount = 0;
	}
	var GrantTotal=(coursefee+hostelfee)-discount;
	$("#total").val(GrantTotal);
	Emi();
}
function Emi()
{	var GrantTotal=$("#total").val();
	var installment=parseInt($('#installment').val());
	var Emi=parseFloat(GrantTotal/installment).toFixed(2);
	$('#emi').html(installment+ "&nbsp;&times;&nbsp;" +Emi + "&nbsp;=&nbsp;" + GrantTotal);
	
}
function grandTotal()
{  
	var courseFee=$("#course_fee").val();
	var hostelFee=isNaN(parseInt($('#hostel_fee').val()))? 0 :parseInt($('#hostel_fee').val()) ;
	var total = parseInt(courseFee)+parseInt(hostelFee);
	$("#total").val(total);
	discount($("#txtdiscount").val());
	Emi();
}

function checkformnumber(str)
{
	
if (window.XMLHttpRequest)
  {  xmlhttp=new XMLHttpRequest();  }
else
  {  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }
xmlhttp.onreadystatechange=function()
  {  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {   
	
	if(xmlhttp.responseText == 1)
	{
		$('#form_number_span').fadeOut(200).hide();
		
	}
	else
	{
	    $('#form_number').val("");
		$('#form_number').focus();
		$('#form_number_span').fadeOut(200).show();
		
		
	}
	 
	 } 
	 
	 }
xmlhttp.open("GET","checkformdetail.php?u="+str,true);
xmlhttp.send();	
	}

 
 
	</script>
     

  </body>
</html>
<?PHP

}
else
{	header("location:index.php");
}
?>
</body>
</html>